<!--tabs-->
<script src="/static/plugins/AdminLTE-2.4/dist/js/app_iframe.js"></script>
<script type="text/javascript">
    /**
     * 本地搜索菜单
     */
    function search_menu() {
        //要搜索的值
        var text = $('input[name=q]').val();
        var $ul = $('.sidebar-menu');
        //取消空搜索
        if(text == ''){
            return false;
        }
        $ul.find("a.nav-link").each(function () {
            var $a = $(this).css("border","");
            //判断是否含有要搜索的字符串
            if ($a.children("span.menu-text").text().indexOf(text) >= 0) {
                //如果a标签的父级是隐藏的就展开
                $ul = $a.parents("ul");
                if ($ul.is(":hidden")) {
                    $a.parents("ul").prev().click();
                }
                //点击该菜单
                $a.click().css("border","1px solid");
				//return false;
            }
        });
    }

    $(function () {
        //console.log(window.location);
        //设置App默认路径
        App.setbasePath("/static/plugins/AdminLTE-2.4/");
		//设置图片默认路径
        App.setGlobalImgPath("dist/img/");
		//设置默认欢迎页
        addTabs({
            id: '1',
            title: '控制台',
            close: false,
            url: '{:url('Index/main')}',
            //urlType: "abosulte",
			icon: "fa fa-dashboard",
        });
		//修正高度
        App.fixIframeCotent();

        var menus = [
           /* {
                id: "9000",
                text: "主导航",
                icon: "",
                isHeader: true
            }, */
			
			//循环读取导航菜单
			{volist name="$menus" id="vo"}
			 {
			    id: "{$vo.id}000",
			    text: "{$vo.title}",
			    icon: "{$vo.icon}",
			    children: [
					{volist name="vo.children" id="voo"}
			        {
			            id: "{$vo.id}000{$voo.id}",
			            text: "{$voo.title}",
			            icon: "{$voo.icon ? $voo.icon :'fa fa-circle-o'}",
			            url: "{$voo.href}",
			            targetType: "iframe-tab", //blank 新页面 ,ajax ,iframe-tab, iframe 单irfame 
						
			        },
					{/volist}
			    ]
			},
			{/volist}
			//循环结束

            /*三级菜单演示 {
                id: "9002",
                text: "表单",
                icon: "fa fa-edit",
                children: [
                    {
                        id: "90021",
                        text: "高级",
                        url: "pages/forms/advanced.html",
                        targetType: "iframe-tab",
                        icon: "fa fa-circle-o"
                    },
                    {
                        id: "90022",
                        text: "一般表单",
                        url: "pages/forms/general.html",
                        targetType: "iframe-tab",
                        icon: "fa fa-circle-o"
                    },
                    {
                        id: "90023",
                        text: "二级菜单",
                        icon: "fa fa-circle-o",
                        children: [
                        	{
		                        id: "90024",
		                        text: "百度",
		                        url: "pages/UI/sliders.html",
		                        targetType: "iframe-tab",
		                        icon: "fa fa-circle-o"
		                    },
		                    {
		                        id: "90025",
		                        text: "SOGO",
		                        url: "pages/UI/icons.html",
		                        targetType: "iframe-tab",
		                        icon: "fa fa-circle-o"
		                    }
                        ]
                    }
                ]
            } */
        ];
        $('.sidebar-menu').sidebarMenu({data: menus});

    });

    //当刷新过来的时候应该查找刷新的菜单并执行模拟点击事件
    {if $refererUrl}
    $(function(){
        var url = '{$refererUrl}';
        //查找url出现的位置
        var active = $("ul.sidebar-menu li a[href='" + url + "']");
        active.trigger("click");
    })
    {/if}

    if (history.pushState) {
        //浏览器前进后退事件
        $(window).on("popstate", function (e) {
            var state = e.originalEvent.state;
            if (state) {
                $("ul.sidebar-menu li a[href='" + state.url + "']").trigger("click");
            }
        });
    }
</script>